/*
 * @Description:
 * @Author: zhaokun
 * @Date: 2022-02-22 15:47:39
 * @LastEditTime: 2022-02-22 16:40:57
 * @FilePath: \user\rpc\taskpool\testTask.go
 */
package taskpool

import (
	"fmt"
	"user/rpc/internal/svc"
)

type testTask struct {
	name string
}

func NewTestTask() *testTask {
	return &testTask{}
}

func (test *testTask) Handler(context *svc.ServiceContext) {
	context.Cache.Set("nameRpc", "testRpc111", 0)
	pub := context.Cache.Subscribe("testRpc", "Rpc")
	defer pub.Close()
	for msg := range pub.Channel() {
		fmt.Println(msg.Payload)
	}
}

func (test *testTask) AsyHandler(context *svc.ServiceContext) {
	context.Cache.Set("nameRpc", "testAsyRpc", 0)
}
